// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Requests;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement;

public sealed partial class MigrateToDataTiersRequestParameters : RequestParameters
{
	/// <summary>
	/// <para>If true, simulates the migration from node attributes based allocation filters to data tiers, but does not perform the migration.<br/>This provides a way to retrieve the indices and ILM policies that need to be migrated.</para>
	/// </summary>
	public bool? DryRun { get => Q<bool?>("dry_run"); set => Q("dry_run", value); }
}

/// <summary>
/// <para>Switches the indices, ILM policies, and legacy, composable and component templates from using custom node attributes and<br/>attribute-based allocation filters to using data tiers, and optionally deletes one legacy index template.+<br/>Using node roles enables ILM to automatically move the indices between data tiers.</para>
/// </summary>
public sealed partial class MigrateToDataTiersRequest : PlainRequest<MigrateToDataTiersRequestParameters>
{
	internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementMigrateToDataTiers;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ilm.migrate_to_data_tiers";

	/// <summary>
	/// <para>If true, simulates the migration from node attributes based allocation filters to data tiers, but does not perform the migration.<br/>This provides a way to retrieve the indices and ILM policies that need to be migrated.</para>
	/// </summary>
	[JsonIgnore]
	public bool? DryRun { get => Q<bool?>("dry_run"); set => Q("dry_run", value); }
	[JsonInclude, JsonPropertyName("legacy_template_to_delete")]
	public string? LegacyTemplateToDelete { get; set; }
	[JsonInclude, JsonPropertyName("node_attribute")]
	public string? NodeAttribute { get; set; }
}

/// <summary>
/// <para>Switches the indices, ILM policies, and legacy, composable and component templates from using custom node attributes and<br/>attribute-based allocation filters to using data tiers, and optionally deletes one legacy index template.+<br/>Using node roles enables ILM to automatically move the indices between data tiers.</para>
/// </summary>
public sealed partial class MigrateToDataTiersRequestDescriptor : RequestDescriptor<MigrateToDataTiersRequestDescriptor, MigrateToDataTiersRequestParameters>
{
	internal MigrateToDataTiersRequestDescriptor(Action<MigrateToDataTiersRequestDescriptor> configure) => configure.Invoke(this);

	public MigrateToDataTiersRequestDescriptor()
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementMigrateToDataTiers;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ilm.migrate_to_data_tiers";

	public MigrateToDataTiersRequestDescriptor DryRun(bool? dryRun = true) => Qs("dry_run", dryRun);

	private string? LegacyTemplateToDeleteValue { get; set; }
	private string? NodeAttributeValue { get; set; }

	public MigrateToDataTiersRequestDescriptor LegacyTemplateToDelete(string? legacyTemplateToDelete)
	{
		LegacyTemplateToDeleteValue = legacyTemplateToDelete;
		return Self;
	}

	public MigrateToDataTiersRequestDescriptor NodeAttribute(string? nodeAttribute)
	{
		NodeAttributeValue = nodeAttribute;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (!string.IsNullOrEmpty(LegacyTemplateToDeleteValue))
		{
			writer.WritePropertyName("legacy_template_to_delete");
			writer.WriteStringValue(LegacyTemplateToDeleteValue);
		}

		if (!string.IsNullOrEmpty(NodeAttributeValue))
		{
			writer.WritePropertyName("node_attribute");
			writer.WriteStringValue(NodeAttributeValue);
		}

		writer.WriteEndObject();
	}
}